# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=SDL2
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.3
pkgrel=2
pkgdesc="A library for portable low-level access to a video framebuffer, audio output, mouse, and keyboard (Version 2) (mingw-w64)"
arch=('any')
url="http://libsdl.org"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs" "${MINGW_PACKAGE_PREFIX}-libiconv")
options=('staticlibs' 'strip')
source=("http://libsdl.org/release/SDL2-$pkgver.tar.gz"
        fix-linker-flags.patch)
md5sums=('fe6c61d2e9df9ef570e7e80c6e822537'
         '932a4c42f068a9117c3c02efead14b29')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}
  patch -p1 -i ${srcdir}/fix-linker-flags.patch
  
  ./autogen.sh
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST}
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  sed -e "s|-mwindows||g" -i ${pkgdir}${MINGW_PREFIX}/lib/pkgconfig/sdl2.pc
}
